package com.yy.controller.mapper;

import com.github.pagehelper.Page;
import com.yy.dto.EmployeePageQueryDTO;
import com.yy.entity.Employee;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.DeleteMapping;

@Mapper
public interface EmployeeMapper {
    /**
     * 条件分页查询
     * @param employeePageQueryDto
     * @return
     */
    Page<Employee> getPageList(EmployeePageQueryDTO employeePageQueryDto);

    /**
     * 删除员工
     * @param id
     */
    @Delete("delete from employee where id = #{id}")
    void deleteEmployee(Long id);

    /**
     * 添加员工
     * @param employee
     */
    @Insert("insert into employee(name,phone,sex,id_number,monthly_salary" +
            ",create_user,update_user,create_time,update_time)" +
            " values(#{name}, #{phone},#{sex},#{idNumber},#{monthlySalary},#{createUser}," +
            "#{updateUser},#{createTime},#{updateTime})")
    void addEmployee(Employee employee);

    /**
     * 修改员工信息
     * @param employee
     */
    @Update("update employee set name=#{name},phone=#{phone},sex=#{sex},id_number=#{idNumber}," +
            "monthly_salary=#{monthlySalary},update_time=#{updateTime},update_user=#{updateUser} where id=#{id}")
    void updateEmployee(Employee employee);
}
